/**

 * ...

 * @author Thot

 */



function SimpleCulling(){}

SimpleCulling.prototype.chidren = null;

SimpleCulling.prototype.addChild 	= function( p_child )
{
	this.children.push( p_child );
};


SimpleCulling.prototype.removeChild = function( p_child )
{
	var index = this.children.indexOf(p_child);
	if( index == -1 )
		return;
		
	this.children.splice( index, 1 );
};

SimpleCulling.prototype.init 	= function()
{
	this.children = new Array();
};

SimpleCulling.prototype.getVisibleChildrenIn = function ( p_x, p_y, p_width, p_height )
{
	var visibles = new Array();
	var tab = this.children;
	var i = 0;
	var j = 0;
	var max = tab.length; 
	
	for( i = 0; i < max; i++ )
	{
		obj = tab[i];
		
		if( obj.x + obj.width < p_x )
			continue;
			
		if( obj.y + obj.height < p_y )
			continue;
			
		if( obj.x > p_x + p_width )
			continue;
			
		if( obj.y > p_y + p_height )
			continue;
		
		visibles[j] = obj;
		j++;
	}
	
	return visibles;
}




//clean
SimpleCulling.prototype.clean = function()
{
	this.children = new Array();
};


//destroy
SimpleCulling.prototype.destroy = function()
{
	this.children = null;
};
